/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package stutterislandserver;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import network.ClientConnection;
import network.ClientConnectionImpl;

/**
 *
 * @author Sundayufo
 */
public class StutterIslandServer {

    public static final int LISTENING_PORT = 20002;

    public static void main(String[] args) throws FileNotFoundException {
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(LISTENING_PORT);
            System.out.println("Server started on port " + LISTENING_PORT);
        } catch (IOException ioe) {
            System.err.println("Can not start listening on port ");
        }


        File f = new File("userDatabase.db");
        UserDatabase.getContact("");
        System.out.println(f.getAbsoluteFile());

        //init databases;

        // Accept and handle client connections
        while (true) {
            try {
                Socket socket = serverSocket.accept();
                ClientConnection connection = new ClientConnectionImpl(socket);

            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }


    }
}
